//
//  NSDate+YSTools.m
//  YsToolsManager
//
//  Created by hle1 on 2021/8/12.
//

#import "NSDate+YSTools.h"
#import <YYCategories/YYCategories.h>

@implementation NSDate (YSTools)
- (NSComparisonResult)hle_compare:(NSDate *)other
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *oneDayStr = [dateFormatter stringFromDate:self];
    NSString *anotherDayStr = [dateFormatter stringFromDate:other];
    NSDate *dateA = [dateFormatter dateFromString:oneDayStr];
    NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
    NSComparisonResult result = [dateA compare:dateB];
    return result;
}

+ (NSDate *)hle_currentDateFormat:(NSString *)format
{
    if (format.isNotBlank) {
        format = @"yyyy-MM-dd";
    }
    NSString *nowtime =  [NSString stringWithFormat:@"%zd-%zd-%zd",NSDate.date.year,NSDate.date.month,(long)NSDate.date.day];
    NSDate *nowDate =  [NSDate dateWithString:nowtime format:format];
    return nowDate;
}
@end
